<template>
  <div>
    <van-field label="标题" v-model="form.title" />
    消息类型：<select name="" id="" v-model="form.notice_type">
      <option value="1">系统消息</option>
      <option value="2">通知消息</option>
    </select>
    <!--    <div class="demo-date-picker">-->
    <!--      <div class="block">-->
    <!--        <span class="demonstration">开始时间</span>-->
    <!--        <el-date-picker-->
    <!--          v-model="value1"-->
    <!--          type="date"-->
    <!--          placeholder="Pick a date"-->
    <!--          :default-value="new Date(2010, 9, 1)"-->
    <!--        >-->
    <!--        </el-date-picker>-->
    <!--      </div>-->
    <!--      <div class="block">-->
    <!--        <span class="demonstration">结束时间</span>-->
    <!--        <el-date-picker-->
    <!--          v-model="value2"-->
    <!--          type="date"-->
    <!--          placeholder="Pick a date"-->
    <!--          :default-value="new Date(2010, 9, 1)"-->
    <!--        >-->
    <!--        </el-date-picker>-->
    <!--      </div>-->
    <!--    </div>-->

    优先级：<select name="" v-model="form.level">
      <option value="1">高级</option>
      <option value="2">中级</option>
      <option value="3">低级</option>
    </select>
    &nbsp;&nbsp;&nbsp;&nbsp;通知类型：<select
      name=""
      @change="changetype"
      v-model="form.type"
    >
      <option value="1">所有用户</option>
      <option value="2">选择角色</option>
      <option value="3">选择用户</option>
    </select>

    <el-dialog v-model="dialogTableVisible" title="Shipping address">
      <depttree @setids="getid" />
    </el-dialog>

    内容：<br /><test2 /><br />
    <button @click="submit">发布</button>
  </div>
</template>

<script>
import { ref } from "vue";
import axios from "axios";
import test2 from "@/components/test2";
import depttree from "@/components/depttree";
export default {
  name: "notice",
  components: {
    test2: test2,
    depttree: depttree,
  },
  data() {
    const value1 = ref("");
    return {
      value1,
      // value2,
      content: "",
      form: { content: "", userids: "" },
      dialogTableVisible: false,
      checkdvalues: [],
    };
  },
  methods: {
    changetype() {
      if (this.form.type == 2 || this.form.type == 3) {
        this.dialogTableVisible = true;
      }
    },
    getid(values) {
      this.checkdvalues = values;
    },
    submit() {
      this.form.content = this.content;
      this.form.userids = this.checkdvalues;
      axios({
        url: "/noticem",
        method: "post",
        data: { form: this.form },
      }).then((res) => {
        console.log(res);
      });
    },
  },
  mounted() {},
};
</script>

<style scoped></style>
